<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML" 4.01"//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!-- Created: August 22, 2001-->
<!--
$Id: MachineModify.php,v 1.5 2001/11/15 21:49:51 eugenem Exp $
$Header: /export/home/eugenem/public_html/ComplianceReports/RCS/MachineModify.php,v 1.5 2001/11/15 21:49:51 eugenem Exp $
$Log: MachineModify.php,v $
Revision 1.5  2001/11/15 21:49:51  eugenem
Added separator bar between the submit buttons.

Revision 1.4  2001/11/02 19:06:37  eugenem
Moved HTTP_*_VARS processing to dbc.inc

Revision 1.3  2001/11/02 14:57:55  eugenem
Moved database connect statements to a separate file.

Revision 1.2  2001/09/11 12:45:43  eugenem
Fix <textarea> field to display current note.

Revision 1.1  2001/09/07 17:43:43  eugenem
Initial revision

-->

<html>
<head>
<title>Radiological Equipment Database</title>
<meta name="author" content="Eugene Mah">
<link rev="made" href="mailto:eugenem@ix.netcom.com">
<link rev="home" href="http://home.netcom.com/~eugenem/">
<meta name="description" content="">
<meta name="Keywords" content="">
<meta name="Reply-to" content="eugenem@ix.netcom.com">
<META http-equiv="PICS-Label" content='(PICS-1.1 "http://www.classify.org/safesurf/" l r (SS~~0001))'>
<?PHP
require('functions.inc');
require('dbc.inc');

?>
</head>

<body>
<h1>Radiological Equipment Database</h1>
<?PHP
if (isset($MachID) && empty($change)) {
  /*
    Machine has been selected.  Display a form showing the current machine
    info and text fields where changes can be entered
  */

  $query = "SELECT Modality,Machines.ModalityID,Description,Manufacturer,Machines.ManufacturerID,
            VendSiteID,Model,SerialNumber,ManufDate,InstallDate,Location,Machines.LocationID,Room,Status,Notes 
			FROM Machines,Modality,Manufacturer,Location 
			WHERE MachineID=$MachID AND Machines.ModalityID=Modality.ModalityID 
			AND Machines.ManufacturerID=Manufacturer.ManufacturerID 
			AND Machines.LocationID=Location.LocationID";
  $result = mysql_query($query)
    or die ("<p>Unable to update status: $query</p>\n");

  $row = mysql_fetch_array($result);

  $modality = mysql_query("select * from Modality order by Modality");
  $manuf = mysql_query("select * from Manufacturer order by Manufacturer");
  $loc = mysql_query("select * from Location order by Location");
?>
<form action="MachineModify.php" method="POST">
<input type="HIDDEN" name="change" value="1">
<input type="HIDDEN" name="MachID" value="<?PHP echo $MachID; ?>">
<p>
<table border=1 cellpadding=3>
  <tr>
    <th>Modality</th><th>Description</th><th>Manufacturer</th><th>Model</th><th>Serial Number</th>
  </tr>
  <tr>
    <td><?PHP echo $row['Modality']; ?></td>
    <td><?PHP echo $row['Description']; ?></td>
    <td><?PHP echo $row['Manufacturer']; ?></td>
    <td><?PHP echo $row['Model']; ?></td>
    <td><?PHP echo $row['SerialNumber']; ?></td>
  </tr>
  <tr>
    <td><?PHP echo listbox_field($modality,"ModalityID",$row['ModalityID']); ?></td>
    <td><input type="TEXT" name="Description" size="25" value="<?PHP echo $row['Description']; ?>"></td>
    <td><?PHP echo listbox_field($manuf,"ManufacturerID",$row['ManufacturerID']); ?></td>
    <td><input type="TEXT" name="Model" size="20" value="<?PHP echo $row['Model']; ?>"></td>
    <td><input type="TEXT" name="SerialNumber" size="20" value="<?PHP echo $row['SerialNumber']; ?>"></td>
  </tr>
</table>
</p>
<p>
<table border=1 cellpadding=3>
  <tr>
    <th>Site ID</th><th>Manufacture Date</th><th>Install Date</th><th>Location</th><th>Room</th><th>Status</th>
  </tr>
  <tr>
    <td><?PHP echo $row['VendSiteID']; ?></td>
    <td><?PHP echo $row['ManufDate']; ?></td>
    <td><?PHP echo $row['InstallDate']; ?></td>
    <td><?PHP echo $row['Location']; ?></td>
    <td><?PHP echo $row['Room']; ?></td>
	<td><?PHP echo $row['Status']; ?></td>
  </tr>
  <tr>
    <td><input type="text" name="VendSiteID" size="20" value="<?PHP echo $row['VendSiteID']; ?>" /></td>
    <td><input type="TEXT" name="ManufDate" size="10" value="<?PHP echo $row['ManufDate']; ?>"></td>
    <td><input type="TEXT" name="InstallDate" size="10" value="<?PHP echo $row['InstallDate']; ?>"></td>
    <td><?PHP echo listbox_field($loc,"LocationID",$row['LocationID']); ?></td>
    <td><input type="TEXT" name="Room" size="20" value="<?PHP echo $row['Room']; ?>"></td>
	<td>
	  <select name="Status" size="1">
        <option value="Active" selected="selected">Active</option>
        <option value="Inactive">Inactive</option>
        <option value="Removed">Removed</option>
      </select>
    </td>
  </tr>
</table>
</p>
<p>
<table border=1 cellpadding=3>
  <tr>
    <th>Notes</th>
  </tr>
  <tr>
    <td><?PHP echo $row['Notes']; ?></td>
  </tr>
  <tr>
    <td><textarea name="Notes" rows="2" cols="70" value="<?PHP echo $row['Notes']; ?>"><?PHP echo $row['Notes']; ?></textarea>
  </tr>
</table>
</p>
<p><input type="SUBMIT" value="Modify"> / <input type="RESET" value="Reset"> / <a href="index.html" target="_top" >Main</a></p>
</form>
<hr>
<?PHP
  mysql_free_result($modality);
  mysql_free_result($manuf);
  mysql_free_result($loc);
  mysql_free_result($result);
}
else if (isset($MachID) && !empty($change)) {
  /*
    Step 2: Changes have been entered, now process them
  */
  $query = "UPDATE Machines SET 
            ModalityID=$ModalityID, Description=\"$Description\", ManufacturerID=$ManufacturerID, 
			VendSiteID=\"$VendSiteID\",Model=\"$Model\", SerialNumber=\"$SerialNumber\", ManufDate=\"$ManufDate\", 
			InstallDate=\"$InstallDate\", LocationID=$LocationID, Status=\"$Status\", Room=\"$Room\", 
			Notes=\"$Notes\" WHERE MachineID=$MachID";

  $result = mysql_query($query)
    or die ("<p>Unable to update: $query</p>\n");

  echo "<h2>Record Updated</h2>\n";
  echo "<p>$Description updated</p>\n";
}
?>
<form action="MachineModify.php" method="POST">
<P>Select a machine to modify
<?PHP
$machines = mysql_query("select MachineID,Description from Machines where Status=\"Active\" order by Description");
echo listbox_field($machines,"MachID","");
?>
</p>
<p><input type="SUBMIT" value="Select"> / <input type="RESET" value="Reset"> / <a href="index.html" target="_top" >Main</a></p>
</form>
<?PHP mysql_close() ?>

</body>
</html>
